package com.wx.entity;


import lombok.extern.slf4j.Slf4j;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.util.Set;

/**
 * @author Administrator
 * @date 2022/12/29 14:23
 **/
@Slf4j
public class ValidationMain {
    public static void main(String[] args) {
        PersonVo personVo = new PersonVo();
        personVo.setEnable(false);

        ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();


        Validator validator = validatorFactory.getValidator();

        Set<ConstraintViolation<PersonVo>> constraintViolations = validator.validate(personVo);
        for (ConstraintViolation<PersonVo> constraintViolation : constraintViolations) {
            log.info(constraintViolation.getMessage());
        }
    }
}
